//转译字符换为普通字符
function escape2Html(str) {
    if (str == null || str == '') return "";
    var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&'};
    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}
//grid处理过的特殊字符转正常
function escapeSign(str) {
    if (str == null || str == '') return "";
    var arrEntities={'¬':'&amp;not','¢':'&amp;cent','£':'&amp;pound','¤':'&amp;curren'};
    return str.replace(/(¬|¢|£|¤)/ig,function(all,t){return arrEntities[t];});
}
//普通字符换为转译字符
function html2Escape(sHtml) {
    return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
}

//去除HTML标签
function removeHtmlTab(tab) {
    return tab.replace(/<[^<>]+?>/g,'');//删除所有HTML标签
}

//回车转为br标签
function return2Br(str) {
    return str.replace(/\r?\n/g,"<br />");
}

//nbsp转为空格
function nbsp2Space(str) {
    var arrEntities = {'nbsp' : ' '};
    return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]})
}

//多个连续空格合并为一个空格
function mergeSpace(str) {
    str=str.replace(/(\s|&nbsp;)+/g,' ');
    return str;
}

//去除开头结尾换行,并将连续3次以上换行转换成2次换行
function trimBr(str) {
    str=str.replace(/((\s|&nbsp;)*\r?\n){3,}/g,"\r\n\r\n");//限制最多2次换行
    str=str.replace(/^((\s|&nbsp;)*\r?\n)+/g,'');//清除开头换行
    str=str.replace(/((\s|&nbsp;)*\r?\n)+$/g,'');//清除结尾换行
    return str;
}